﻿#ifndef ELEMENTDELEGATE_H
#define ELEMENTDELEGATE_H

#include <QStyledItemDelegate>
#include <QPainter>
#include <QFont>
class ElementDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    ElementDelegate(QObject *parent = nullptr)
        :QStyledItemDelegate(parent)
    {}
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
    void paintBackground(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)const;
    void paintText(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void paintIcon(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
    QFont mFont = QFont();
    mutable QSize iconSize;
};

#endif // ELEMENTDELEGATE_H
